// pages/login/index.js
Page({
  data: {
    email:"",
    password:"",
 
  },
  handleGetUserInfo(e){
    const{userInfo}=e.detail;
    wx.setStorageSync('userInfo', userInfo);
    wx.navigateBack({
      delta:1
    });
  },
  usernameInput: function (event) {
    this.setData({ email: event.detail.value })
  },
  passwordInput: function (event) {
    this.setData({ password: event.detail.value })
  },

// 登录
login: function () {
  var that = this;
  if (this.data.email.length == 0 || this.data.password.length == 0) {
    wx.showToast({
      title: '账号或密码不能为空',
      icon: 'none',
      duration: 2000
    })
  } else {
    wx.request({
      url: 'http://120.78.160.172:8002/api/Login/Login', // 仅为示例，并非真实的接口地址
      data: {
        email: that.data.email,
        password: that.data.password
      },  
      method: 'GET',
      success(res) {
        if (res.data.code == "OK") {     
          wx.switchTab({
            url: '../user/index'
          })
        } else {
          wx.showModal({                                                           
            content: "用户名或者密码输入不正确"
          });
        }
      }
    })
  }
}

})